package com.myworkbench.workbench.domain.valueobject;

import com.myworkbench.workbench.domain.ValueObject;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.NonNull;

import javax.persistence.*;
import java.time.LocalDateTime;


@Data
@Embeddable
@AllArgsConstructor
@NoArgsConstructor
public final class Creator extends ValueObject<Creator> {
  @NonNull
  @Column(length = 11,nullable = false,updatable = false)
  private Integer createUserId;
  @Column(length = 50,nullable = false,updatable = false)
  private String createRealName;
  @Column(nullable = false,updatable = false)
  private LocalDateTime createTime;
  /**
   * @desc 覆盖equals方法
   */
  @Override
  public boolean equals(Object obj){
    if(obj == null){
      return false;
    }
    //如果是同一个对象返回true，反之返回false
    if(this == obj){
      return true;
    }
    //判断是否类型相同
    if(this.getClass() != obj.getClass()){
      return false;
    }
    Creator creator = (Creator)obj;
    return this.createUserId == creator.createUserId;
  }

  @Override
  public boolean sameValueAs(Creator other) {
    return false;
  }
}
